package com.pubinfo.passbook.api.controller.contract;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pubinfo.passbook.common.entity.TContractPerformance;
import com.pubinfo.passbook.common.model.dto.contract.ContractIdParam;
import com.pubinfo.passbook.common.model.vo.base.JsonResult;
import com.pubinfo.passbook.common.service.contract.TContractPerformanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@Slf4j
@RestController
@Api(tags = "QGPB-合同收款计划")
@RequestMapping(value = "contractPerformance")
public class ContractPerformanceController {

    @Resource
    private TContractPerformanceService contractPerformanceService;

    @PostMapping
    @ApiOperation(value = "获取合同收款计划")
    public JsonResult<List<TContractPerformance>> list(@RequestBody @Valid ContractIdParam param) {
        QueryWrapper<TContractPerformance> qw = new QueryWrapper<>();

        qw.lambda().eq(TContractPerformance::getContractId, param.getContractId());

        return JsonResult.success(contractPerformanceService.list(qw));
    }

}
